﻿
Imports elpmis
Imports lpmsengi
Imports occommon

Public Class userSetUI
    Inherits userSet

    Public Shadows Const _pathidentity As String = network.pathSeperator + path.userSetUI

    Shared Sub New()
        assert(Not strstartwith(path.userSetUI, network.pathSeperator))
    End Sub

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Private Shared Function processResponse(ByVal context As httpContext,
                                            ByVal statusCode As Int64,
                                            ByVal statusDescription As String) As Boolean
        elpmis.context.insertThreadStaticVariable("statusCode", typeDefination.int, statusCode)
        elpmis.context.insertThreadStaticVariable("statusDescription", typeDefination.string, statusDescription)
        Dim status As String = Nothing
        If statusCode = response.statusCode.success AndAlso
           strsame(statusDescription, response.description.success) Then
            status = "suc"
        ElseIf statusCode = response.statusCode.noUserInput AndAlso
               strsame(statusDescription, response.description.noUserInput) Then
            status = "nouser"
        ElseIf statusCode = response.statusCode.noSiteInput AndAlso
               strsame(statusDescription, response.description.noSiteInput) Then
            status = "nosite"
        ElseIf statusCode = response.statusCode.noOnlineCookieUserSiteRandomKeyInput AndAlso
               strsame(statusDescription, response.description.noOnlineCookieUserSiteRandomKeyInput) Then
            status = "nousrk"
        ElseIf statusCode = response.statusCode.invalidSiteInput AndAlso
               strsame(statusDescription, response.description.invalidSiteInput) Then
            status = "invalidsite"
        ElseIf statusCode = response.statusCode.onlineCookieUserSiteRandomKeyError AndAlso
               strsame(statusDescription, response.description.onlineCookieUserSiteRandomKeyError) Then
            status = "usrkerr"
        ElseIf statusCode = setResponse.statusCode.noCookiesInput AndAlso
               strsame(statusDescription, setResponse.description.noCookiesInput) Then
            status = "nocookie"
        Else
            status = "internal"
        End If
        elpmis.context.insertThreadStaticVariable("status", typeDefination.string, status)
        Return context.createControl(New nameLpmsControl("setresp")).render()
    End Function

    Public Overrides Function process(ByVal context As httpContext) As Boolean
        If MyBase.process(context) Then
            Return processResponse(context, context.response().StatusCode, context.response().StatusDescription)
            Return True
        Else
            Return False
        End If
    End Function
End Class
